#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int main() {
    int year, month, day;
    int count = 0;

    int months[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
    scanf("%d %d %d", &year, &month, &day);
    if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {
        months[1] = 29;
    }
    if ((year >= 1000 && year <= 9999) && (month >= 1 && month <= 12) && (day >= 1 && day <= months[month - 1])) {
        if (month == 1) {
            count = day;
        }
        else {
            for (int i = 1; i < month; i++) {
                count = count + months[i - 1];
            }
            count = count + day;
            printf("%d", count);
        }


    }


    return 0;
}